package com.app.server.impl;

import com.app.mapper.MobileMapper;
import com.app.model.MobileModel;
import com.app.server.MobileService;
import com.app.utils.StringTool;
import com.app.vo.MobileVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
//报灾专线
@Service
public class MobileServiceImpl extends ServiceImpl<MobileMapper, MobileModel> implements MobileService {
    @Autowired
    private MobileMapper mobileMapper;
    @Override
    public MobileVo getMobileList(Integer page, Integer limit, String name) {
        Page<MobileModel> page1 = new Page<>(page, limit);

        QueryWrapper<MobileModel> qw =new QueryWrapper<>();
        if (StringTool.isNotEmpty(name)){
            qw.like("name",name);
        }
        qw.orderByDesc("id");
        Page<MobileModel> mobilePage = mobileMapper.selectPage(page1, qw);
        List<MobileModel> mobileList = mobilePage.getRecords();

        long count = mobilePage.getTotal();
        MobileVo mobileVo = new MobileVo();
        mobileVo.setList(mobileList);
        mobileVo.setCount((int) count);
        return mobileVo;
    }
}
